Skip to content

Conversation

roeyfredi
Copy link

No description provided.

print (mostapperdword)
print(max(d.values()))

print(f'The word that returns most times in the text file is: ' +mostapperdword+ ' and it returns ' ,max(d.values())) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax error

@@ -0,0 +1,21 @@
text = open('text.txt', 'r')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened file need to closed. best practice is to use "with...open..."

@@ -0,0 +1,21 @@
text = open('text.txt', 'r')
d = dict()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable name should be meaningful

for key in list(d.keys()):
print(key, ":", d[key])

mostapperdword=max(d,key=d.get)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to python style guide, var name should look like this: most_apperd_word

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants